import request from '@/utils/request'

/** 授权第三方账号
 * @param {string} code
 * @return {Promise<unknown>}
 */
export function oauth(code) {
  return request({
    url: '/social/grant/oauth',
    method: 'post',
    data: {
      code,
      source: 'wechat_open'
    }
  })
}

/** 授权第三方账号
 * @param {string} identity
 * @return {Promise<unknown>}
 */
export function identity(identity) {
  return request({
    url: '/social/grant/identity',
    method: 'post',
    data: {
      identity,
      source: 'apple'
    }
  })
}

/** 解绑第三方账号
 *
 * @param {'wechat_open'|'apple'} source
 * @return {Promise<unknown>}
 */
export function unbind(source) {
  return request({
    url: '/social/unbind',
    method: 'delete',
    params:{
      source,
    }
  })
}
